package start;

import java.io.IOException;
import java.util.Vector;

import javax.swing.UIManager;
import GUI.LaunchController;
import IO.Read;
import Error.Error;
import data.Show;

/**
 * Launch is used to start up sonny.
 * @author quinnjn
 * @troll BionicWeasel
 */
public class Launch 
{
	private String version = "Sonny Alpha 0.2";
	/**
	 * Sonny's startup engine.
	 * @param args
	 * @throws InterruptedException 
	 * @throws IOException 
	 */
	public Launch(String[] args) throws IOException, InterruptedException
	{
		this.preload();
		/*
		//Check for any arguments
		for(int i = 0; i<args.length; i++)
		{
			if(args[i].equals("ndebug"))
			{
				runTests = false;
			}
		}
		*/
		//Add the shutdown listener.
		Shutdown shutdown = new Shutdown();
		Runtime.getRuntime().addShutdownHook(new Thread(shutdown));

		//Make the heartbeat.
		Heartbeat heartbeat = new Heartbeat();
		Thread heartbeatThread = new Thread(heartbeat);
		
		//Start the heartbeat.
		heartbeatThread.start();
		
		//Start GUI
		new LaunchController(version);
		
		//Start CLI
		//CLI cli = new CLI(showList, version);
		//cli.run();
	}
		
	private void preload() 
	{
		//Start the error class.
		new Error();
		try 
		{
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		} 
		catch (Exception e)
		{
			Error.report(50);
		}
	}
	public static void main(String[] args) throws Exception
	{
		new Launch(args);
	}

}
